#游戏指示器面板
import pygame
from game_items import *
#创建指示器面板类
class HubPanel(object):
    # 指示器面板类
    margin = 10
    white = (255, 255, 255)
    gray = (64, 64, 64)
    #初始化
    def __init__(self, display_group):
        self.score = 0              #游戏得分
        self.lives_count = 3        #生命计数
        self.level = 1              #关卡级别
        self.best_score = 0         #最好成绩
        #创建图像精灵
        #状态精灵
        self.status_sprite = StatusButton(("pause.png","resume.png"),display_group)
        self.status_sprite.rect.topleft = (self.margin,self.margin)
        #炸弹精灵
        self.bomb_sprite = GameSprite("bomb.png", 0,display_group)
        self.bomb_sprite.rect.x = self.margin
        self.bomb_sprite.rect.bottom = SCREEN_RECT.bottom - self.margin
        #生命计数精灵
        right_change = 50
        self.lives_sprite = GameSprite("life.png", 0,display_group)
        self.lives_sprite.rect.right = SCREEN_RECT.right - self.margin - right_change
        self.lives_sprite.rect.bottom = SCREEN_RECT.bottom - self.margin
        #创建标签精灵
        #分数标签
        self.score_label = Label("%d" % self.score, 32, self.gray,display_group)
        self.score_label.rect.midleft = (self.status_sprite.rect.right - self.margin,self.status_sprite.rect.centery)
        #炸弹标签
        self.bomb_label = Label('X 3',32,self.gray,display_group)
        self.bomb_label.rect.midleft = (self.bomb_sprite.rect.right + self.margin,self.bomb_sprite.rect.centery)
        #生命计数标签
        self.lives_label = Label('X %d' % self.lives_count,32,self.gray,display_group)
        self.lives_label.rect.midleft = (SCREEN_RECT.right - right_change,self.bomb_label.rect.centery)
        #调整生命计数精灵位置
        # self.lives_sprite.rect.right = self.lives_label.rect.left - self.margin
        #最好成绩标签
        self.best_label = Label("Best:%d" % self.best_score,36,self.white,display_group)
        self.best_label.rect.center = SCREEN_RECT.center
        #状态标签
        self.status_label = Label('Game Over!',48,self.white,display_group)
        self.status_label.rect.midbottom = (self.best_label.rect.centerx,self.best_label.rect.y - 2 * self.margin)
        #提示标签
        self.tip_label = Label('Press spacebar to play again.',22,self.white,display_group)
        self.tip_label.rect.midtop = (self.best_label.rect.centerx,self.best_label.rect.bottom + 8 * self.margin)
    def show_bomb(self,count):
        #设置炸弹标签文字
        self.bomb_label.set_text('X %d' % count)
        #设置炸弹标签位置
        self.bomb_label.rect.midleft = (self.bomb_sprite.rect.right + self.margin,self.bomb_sprite.rect.centery)
